package com.service.uai.engine.pack;

import com.bpms.common.CommonUtil;
import com.bpms.common.VO;
import com.bpms.eai.IPackage;
import com.bpms.eai.PackTool;
import com.bpms.esb.SV;

public class HDPrintClientPack extends PackTool implements IPackage {

	public VO parseBuffer(byte[] buffer) {
		VO retvo = new VO();
		VO vo = new VO();
		String s = new String(buffer);
		vo.setAttr("message", s);
		retvo = SV.g("UAI.Parsehdprintxml", vo);

		CommonUtil.debug("HDPrintClientPack-parseBuffer:" + retvo);
		return retvo;
	}

	public byte[] prepareBuffer(String svname, VO args) {
		VO retvo = SV.g("UAI.Buildhdprintxml", args);
		byte[] r = null;
		try {
			int len = 0;
			r = retvo.getAttr("message").toString().getBytes("gb2312");
			len = r.length;
			String strLen = String.valueOf(len);
			strLen = addleft0(strLen, 8);
			// byte len[]=PackageTool.intToByte2(r.length);
			return memmerge(strLen.getBytes(), r);
		} catch (Exception e) {
			CommonUtil.debug("HDPrintClientPack.prepareBuffer exception", e);
			return null;
		}
	}

}
